#
# packet template
#
# Copyright (C) 2009 by chrisv <me@cv.gd>
#          
# See CREDITS for details about who has contributed to this project.
#
# For further information about the pdaXrom project and license conditions
# see the README file.
#

LIBSPEUTILS_VERSION=0.1
LIBSPEUTILS=speutils-${LIBSPEUTILS_VERSION}.tgz
LIBSPEUTILS_MIRROR=http://speutils.googlecode.com/files/
LIBSPEUTILS_DIR=$BUILD_DIR/speutils-${LIBSPEUTILS_VERSION}
LIBSPEUTILS_ENV="$CROSS_ENV_AC"

build_libspeutils() {
    test -e "$STATE_DIR/libspeutils.installed" && return
    banner "Build libspeutils"
    download $LIBSPEUTILS_MIRROR $LIBSPEUTILS
    extract $LIBSPEUTILS
    apply_patches $LIBSPEUTILS_DIR $LIBSPEUTILS
    pushd $TOP_DIR
    cd $LIBSPEUTILS_DIR
    (
    sh update.sh
    eval \
	$CROSS_CONF_ENV \
	$LIBSPEUTILS_ENV \
	./configure --build=$BUILD_ARCH --host=$TARGET_ARCH \
	    --prefix=/usr \
	    --sysconfdir=/etc \
	    || error
    ) || error "configure"
    
    make $MAKEARGS || error

    install_sysroot_files || error

    # install libspeutils.so
    $INSTALL -D -m 644 .libs/libspeutils.so.0.1.0 $ROOTFS_DIR/usr/lib/libspeutils.so.0.1.0 || error
    ln -sf libspeutils.so.0.1.0 $ROOTFS_DIR/usr/lib/libspeutils.so.0
    ln -sf libspeutils.so.0.1.0 $ROOTFS_DIR/usr/lib/libspeutils.so
    $STRIP $ROOTFS_DIR/usr/lib/libspeutils.so.0.1.0

    popd
    touch "$STATE_DIR/libspeutils.installed"
}

build_libspeutils
